//
//  ToastModule.m
//  ZgcBank
//
//  Created by 球 on 2023/5/10.
//

#import "ToastModule.h"
#import "HippyBundleURLProvider.h"
#import "HippyRootView.h"
#import "MBProgressHUD.h"
#import "AppDelegate.h"

@interface ToastModule ()<HippyBridgeDelegate>

@end

@implementation ToastModule

HIPPY_EXPORT_MODULE()

- (dispatch_queue_t)methodQueue
{
  return dispatch_get_main_queue();
}

HIPPY_EXPORT_METHOD(toast:(nonnull NSString *)msg)
{
  AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  UIViewController *nav = delegate.window.rootViewController;
  MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:nav.view animated:YES];
  
  // Set the text mode to show only text.
  hud.mode = MBProgressHUDModeText;
  hud.label.text = msg;
  // Move to bottm center.
  //  hud.offset = CGPointMake(0.f, MBProgressMaxOffset);
  
  [hud hideAnimated:YES afterDelay:1.2f];
}

@end
